package com.zw.mes.module.assemble.controller;

import com.zw.mes.base.BaseController;
import com.zw.mes.common.JsonResult;
import com.zw.mes.module.assemble.model.TestModel;
import com.zw.mes.module.assemble.service.TransSelService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 电子转序单查询
 * <p>
 * 权限：
 * @Author: China.wsg
 * @Date: 2021/04/28 10:26
 */
@Controller
@RequestMapping("/assemble/transSel")
@SuppressWarnings("all")
public class TransSelController extends BaseController {

    @Autowired
    private TransSelService transSelService;

    @GetMapping("/selPage")
    @RequiresPermissions({"asseOrd:quacon:view"})
    public String addPage() {
        return "assemble/tranSel/transSel";
    }

    /**
     * 电子转序单查询
     *
     * @return
     */
    @ResponseBody
    @PostMapping("/selList")
    @RequiresPermissions({"asseOrd:quacon:view"})
    public JsonResult selList(TestModel testModel) {
        startPage();
        List<TestModel> list = transSelService.findTransByCondition(testModel);
        return jsonResult(list);
    }

    /**
     * 电子转序单 页面
     * @param id
     * @param model
     * @return
     */
    @GetMapping("/view/{id}")
    @RequiresPermissions({"asseOrd:quacon:view"})
    public String view(@PathVariable("id") Integer id, Model model) {
        model.addAttribute("id", id);
        return "assemble/tranSel/transView";
    }

    /**
     * 电子转序单 数据
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/loadTransOrderData")
    @RequiresPermissions({"asseOrd:quacon:view"})
    public JsonResult loadTransOrderData(Integer id){
        return transSelService.loadTransOrderData(id);
    }

}
